from models.database import get_db_session
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    username = Column(String(50), unique=True)
    password = Column(String(100))  # 建议存储哈希后的密码

def authenticate(username, password):
    """验证用户凭据"""
    session = get_db_session()
    user = session.query(User).filter_by(username=username, password=password).first()
    return user is not None